﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Product.aspx.cs" Inherits="admin_Product" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Panel ID="Panel1" runat="server" GroupingText="Product">
        ProductId:<asp:TextBox ID="txtId" runat="server"></asp:TextBox>
        <br />
        ProductName:<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
        <br />
        CategoryId:<asp:TextBox ID="txtCategoryId" runat="server"></asp:TextBox>
        <br />
        Size:<asp:TextBox ID="txtSize" runat="server"></asp:TextBox>
        <br />
        Color:<asp:TextBox ID="txtColor" runat="server"></asp:TextBox>
        <br />
        Price:<asp:TextBox ID="txtPrice" runat="server"></asp:TextBox>
        <br />
        Image:<asp:TextBox ID="txtImage" runat="server"></asp:TextBox>
        <br />
        <asp:Button ID="btnSave" runat="server" Text="Save" onclick="btnSave_Click" 
            style="height: 26px; width: 42px" />
        <asp:Button ID="btnEdit" runat="server" Text="Edit" />
        <asp:Button ID="btnDelete" runat="server" Text="Delete" />
        <asp:Button ID="btnCancel" runat="server" Text="Cancel" />
        <br />
        <br />
        <asp:GridView ID="grvProduct" runat="server" AutoGenerateColumns="False" 
            DataKeyNames="ProductId" DataSourceID="SqlDataSource1" >
            <Columns>
                <asp:BoundField DataField="ProductId" HeaderText="ProductId" ReadOnly="True" 
                    SortExpression="ProductId" />
                <asp:BoundField DataField="ProductName" HeaderText="ProductName" 
                    SortExpression="ProductName" />
                <asp:BoundField DataField="CategoryId" HeaderText="CategoryId" 
                    SortExpression="CategoryId" />
                <asp:BoundField DataField="Size" HeaderText="Size" SortExpression="Size" />
                <asp:BoundField DataField="Color" HeaderText="Color" SortExpression="Color" />
                <asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
                <asp:BoundField DataField="Url_img" HeaderText="Url_img" 
                    SortExpression="Url_img" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ASPDB %>" 
            DeleteCommand="DELETE FROM [Products] WHERE [ProductId] = @ProductId" 
            InsertCommand="INSERT INTO [Products] ([ProductId], [ProductName], [CategoryId], [Size], [Color], [Price], [Url_img]) VALUES (@ProductId, @ProductName, @CategoryId, @Size, @Color, @Price, @Url_img)" 
            SelectCommand="SELECT * FROM [Products]" 
            UpdateCommand="UPDATE [Products] SET [ProductName] = @ProductName, [CategoryId] = @CategoryId, [Size] = @Size, [Color] = @Color, [Price] = @Price, [Url_img] = @Url_img WHERE [ProductId] = @ProductId">
            <DeleteParameters>
                <asp:Parameter Name="ProductId" Type="String" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="ProductId" Type="String" />
                <asp:Parameter Name="ProductName" Type="String" />
                <asp:Parameter Name="CategoryId" Type="String" />
                <asp:Parameter Name="Size" Type="Int32" />
                <asp:Parameter Name="Color" Type="String" />
                <asp:Parameter Name="Price" Type="Double" />
                <asp:Parameter Name="Url_img" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="ProductName" Type="String" />
                <asp:Parameter Name="CategoryId" Type="String" />
                <asp:Parameter Name="Size" Type="Int32" />
                <asp:Parameter Name="Color" Type="String" />
                <asp:Parameter Name="Price" Type="Double" />
                <asp:Parameter Name="Url_img" Type="String" />
                <asp:Parameter Name="ProductId" Type="String" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <br />
        <asp:ListView ID="ListView1" runat="server" DataKeyNames="ProductId" 
            DataSourceID="SqlDataSource1" InsertItemPosition="LastItem">
            <AlternatingItemTemplate>
                <td runat="server" style="background-color:#FFF8DC;">
                    ProductId:
                    <asp:Label ID="ProductIdLabel" runat="server" Text='<%# Eval("ProductId") %>' />
                    <br />
                    ProductName:
                    <asp:Label ID="ProductNameLabel" runat="server" 
                        Text='<%# Eval("ProductName") %>' />
                    <br />
                    CategoryId:
                    <asp:Label ID="CategoryIdLabel" runat="server" 
                        Text='<%# Eval("CategoryId") %>' />
                    <br />
                    Size:
                    <asp:Label ID="SizeLabel" runat="server" Text='<%# Eval("Size") %>' />
                    <br />
                    Color:
                    <asp:Label ID="ColorLabel" runat="server" Text='<%# Eval("Color") %>' />
                    <br />
                    Price:
                    <asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>' />
                    <br />
                    Url_img:
                    <asp:Label ID="Url_imgLabel" runat="server" Text='<%# Eval("Url_img") %>' />
                    <br />
                    <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                    <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                        Text="Delete" />
                </td>
            </AlternatingItemTemplate>
            <EditItemTemplate>
                <td runat="server" style="background-color:#008A8C;color: #FFFFFF;">
                    ProductId:
                    <asp:Label ID="ProductIdLabel1" runat="server" 
                        Text='<%# Eval("ProductId") %>' />
                    <br />
                    ProductName:
                    <asp:TextBox ID="ProductNameTextBox" runat="server" 
                        Text='<%# Bind("ProductName") %>' />
                    <br />
                    CategoryId:
                    <asp:TextBox ID="CategoryIdTextBox" runat="server" 
                        Text='<%# Bind("CategoryId") %>' />
                    <br />
                    Size:
                    <asp:TextBox ID="SizeTextBox" runat="server" Text='<%# Bind("Size") %>' />
                    <br />
                    Color:
                    <asp:TextBox ID="ColorTextBox" runat="server" Text='<%# Bind("Color") %>' />
                    <br />
                    Price:
                    <asp:TextBox ID="PriceTextBox" runat="server" Text='<%# Bind("Price") %>' />
                    <br />
                    Url_img:
                    <asp:TextBox ID="Url_imgTextBox" runat="server" Text='<%# Bind("Url_img") %>' />
                    <br />
                    <asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
                        Text="Update" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                        Text="Cancel" />
                </td>
            </EditItemTemplate>
            <EmptyDataTemplate>
                <table style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
                    <tr>
                        <td>
                            No data was returned.</td>
                    </tr>
                </table>
            </EmptyDataTemplate>
            <InsertItemTemplate>
                <td runat="server" style="">
                    ProductId:
                    <asp:TextBox ID="ProductIdTextBox" runat="server" 
                        Text='<%# Bind("ProductId") %>' />
                    <br />
                    ProductName:
                    <asp:TextBox ID="ProductNameTextBox" runat="server" 
                        Text='<%# Bind("ProductName") %>' />
                    <br />
                    CategoryId:
                    <asp:TextBox ID="CategoryIdTextBox" runat="server" 
                        Text='<%# Bind("CategoryId") %>' />
                    <br />
                    Size:
                    <asp:TextBox ID="SizeTextBox" runat="server" Text='<%# Bind("Size") %>' />
                    <br />
                    Color:
                    <asp:TextBox ID="ColorTextBox" runat="server" Text='<%# Bind("Color") %>' />
                    <br />
                    Price:
                    <asp:TextBox ID="PriceTextBox" runat="server" Text='<%# Bind("Price") %>' />
                    <br />
                    Url_img:
                    <asp:TextBox ID="Url_imgTextBox" runat="server" Text='<%# Bind("Url_img") %>' />
                    <br />
                    <asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
                        Text="Insert" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                        Text="Clear" />
                </td>
            </InsertItemTemplate>
            <ItemTemplate>
                <td runat="server" style="background-color:#DCDCDC;color: #000000;">
                    ProductId:
                    <asp:Label ID="ProductIdLabel" runat="server" Text='<%# Eval("ProductId") %>' />
                    <br />
                    ProductName:
                    <asp:Label ID="ProductNameLabel" runat="server" 
                        Text='<%# Eval("ProductName") %>' />
                    <br />
                    CategoryId:
                    <asp:Label ID="CategoryIdLabel" runat="server" 
                        Text='<%# Eval("CategoryId") %>' />
                    <br />
                    Size:
                    <asp:Label ID="SizeLabel" runat="server" Text='<%# Eval("Size") %>' />
                    <br />
                    Color:
                    <asp:Label ID="ColorLabel" runat="server" Text='<%# Eval("Color") %>' />
                    <br />
                    Price:
                    <asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>' />
                    <br />
                    Url_img:
                    <asp:Label ID="Url_imgLabel" runat="server" Text='<%# Eval("Url_img") %>' />
                    <br />
                    <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                    <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                        Text="Delete" />
                </td>
            </ItemTemplate>
            <LayoutTemplate>
                <table runat="server" border="1" 
                    style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
                    <tr runat="server" ID="itemPlaceholderContainer">
                        <td runat="server" ID="itemPlaceholder">
                        </td>
                    </tr>
                </table>
                <div style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
                    <asp:DataPager ID="DataPager1" runat="server">
                        <Fields>
                            <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                ShowNextPageButton="False" ShowPreviousPageButton="False" />
                            <asp:NumericPagerField />
                            <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" 
                                ShowNextPageButton="False" ShowPreviousPageButton="False" />
                        </Fields>
                    </asp:DataPager>
                </div>
            </LayoutTemplate>
            <SelectedItemTemplate>
                <td runat="server" 
                    style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;">
                    ProductId:
                    <asp:Label ID="ProductIdLabel" runat="server" Text='<%# Eval("ProductId") %>' />
                    <br />
                    ProductName:
                    <asp:Label ID="ProductNameLabel" runat="server" 
                        Text='<%# Eval("ProductName") %>' />
                    <br />
                    CategoryId:
                    <asp:Label ID="CategoryIdLabel" runat="server" 
                        Text='<%# Eval("CategoryId") %>' />
                    <br />
                    Size:
                    <asp:Label ID="SizeLabel" runat="server" Text='<%# Eval("Size") %>' />
                    <br />
                    Color:
                    <asp:Label ID="ColorLabel" runat="server" Text='<%# Eval("Color") %>' />
                    <br />
                    Price:
                    <asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>' />
                    <br />
                    Url_img:
                    <asp:Label ID="Url_imgLabel" runat="server" Text='<%# Eval("Url_img") %>' />
                    <br />
                    <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                    <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                        Text="Delete" />
                </td>
            </SelectedItemTemplate>
        </asp:ListView>
        <br />
    </asp:Panel>
    </form>
</body>
</html>
